import { createRouter, createWebHashHistory } from 'vue-router'


const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "layout",
      component: () => import("@/views/layout/Layout.vue"),
      redirect:"/home",
      children: [
        {
          path: "/home",
          name: "home",
          component: () => import("@/views/layout/Home.vue"),
        },
        {
          path: "/beddetails",
          name: "beddetails",
          component: () => import("@/views/bed/BedManager.vue"),
        },
        {
          path: "/bedMap",
          name: "bedMap",
          component: () => import("@/views/bed/BedMap.vue"),
        },{
          path: "/nurseLevel",
          name: "nurseLevel",
          component: () => import("@/views/nurse/NurseLevel.vue"),
        },
        {
          path: "/nurseItemToLevel",
          name: "nurseItemToLevel",
          component: () => import("@/views/nurse/NurseItemToLevel.vue"),
        },
        {
          path: "/nurseContent",
          name: "nurseContent",
          component: () => import("@/views/nurse/NurseContent.vue"),
        },
        {
          path: "/checkin",
          name: "checkin",
          component: () => import("@/views/customer/Customer.vue"),
        },
      ],
    },
    {
      path: '/:pathMatch(.*)*',
      component: () => import('@/views/NotFound.vue')
    }
  ]
});

//全局的路由守卫
/* router.beforeEach((to, from, next) => {
	let toPath = to.path;
	// if (toPath === '/login'|| whitelist.indexOf(toPath) == -1) {
	if (toPath === '/login'|| toPath === '/register') {
		next()
	} else {   //     /
		//判断是否存在登录状态
		const token = store.state.token;
		if (token) {
			//可以放行
			next();
		} else {
			//没有登录去登录
			next("/login");
		}
	}
}) */

export default router
